﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Pages_Carrier_TripRule : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!IsPostBack)
			BindControls();
	}

	private void BindControls()
	{
		rptTripRules.DataSource = DBEntity<TripRule>.ExecAsDataset(new TripRule(), "TripRule_schedule");
		rptTripRules.DataBind();
	}

	protected void OnViewGenerateWindow(object s, EventArgs e)
	{
		hfModalAction.Value = (s as LinkButton).CommandArgument;
		tbDateFrom.Text = tbDateTo.Text = string.Empty;
		MPE.Show();
	}

	protected void OnGenerate(object s, EventArgs e)
	{
		TripRule tr = new TripRule();
		tr.StartDT = DS.ToDateTime(tbDateFrom.Text);
		tr.EndDT = DS.ToDateTime(tbDateTo.Text);
		tr.Id = DS.ToInt64(hfModalAction.Value);
		DBEntity<TripRule>.Exec(tr, "TripRule_Generate");
		MPE.Hide();
	}
}
